lcPaint_ImageResize Home

This function performs resampling (or scaling, zooming) of a greyscale or RGB image to the desired destination width and height.
Resampling refers to changing the pixel dimensions (and therefore display size) of an image. When you downsample (or decrease the number of pixels), information is deleted from the image. When you upsample (or increase the number of pixels), new pixels are added based on color values of existing pixels. You specify an interpolation filter to determine how pixels are added or deleted.

 BOOL lcPaint_ImageResize (
   HANDLE hImage,
   int NewWidth,
   int NewHeight,
   int Filter
 );

Parameters
hImage
  Handle to raster image object.
NewWidth
  Destination image width (pixels)
NewHeight
  Destination image height (pixels)
Filter
  The following filters can be used as resampling filters:

Filter flag Description
LC_IMGRES_BOX Box, pulse, Fourier window, 1st order (constant) B-Spline
LC_IMGRES_BILINEAR Bilinear filter
LC_IMGRES_BSPLINE 4th order (cubic) B-Spline
LC_IMGRES_BICUBIC Mitchell and Netravali's two-param cubic filter
LC_IMGRES_CATMULLROM Catmull-Rom spline, Overhauser spline
LC_IMGRES_LANCZOS3 Lanczos-windowed sinc filter


Return Value

  If the function succeeds, the return value is nonzero (TRUE).


Code sample:
//-----------------------------------------------
void LcAppDemo01::LoadImages ()
{
  ...
  // copy image 11, then reduce resolution 4 times
  hImage2 = lcPaint_ImageAdd( 13 );
  lcPaint_ImageCopy( hImage, hImage2 );
  W = lcPropGetInt( hImage2, LC_PROP_IMAGE_W ) / 4;
  H = lcPropGetInt( hImage2, LC_PROP_IMAGE_H ) / 4;
  lcPaint_ImageResize( hImage2, W, H, LC_IMGRES_BICUBIC );
  ...
}